package com.example.demo.reflect;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * @desc:
 * @author: fuxiang
 * @date: 2018/3/5 20:12
 */
public class Reflect {
    public final static   Map<String,String> kmap = new HashMap<String,String>();
    static {
        kmap.put("key", "111111");
    }

    public static  void MapToBean(Map<String,Object> map,Object object,Field[] fields) throws IllegalAccessException {
          if(map.isEmpty()){
              return;
          }
          for(Field field:fields){
              Object o = map.get(field.getName());
              field.setAccessible(true);//暴力反射，解除私有限定
              field.set(object,o);
          }
      }
}
